Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dss commands exit codes and logging #90

Merged
merged 9 commits into from
Apr 24, 2024

Conversation

NohaIhab
Copy link
Contributor

@NohaIhab NohaIhab commented Apr 23, 2024

closes #78

Note: Integration tests in the CI are failing due to microsoft/linux-package-repositories#130, but they can be run locally with tox -e integration

Summary

Refactors the following dss commands:

  • create
  • initialize
  • logs
  • remove
  • status
  • stop

With the following changes:

  1. use logger.debug to store the error with traceback
  2. exit with 1 exit code in failure cases
  3. raise RuntimeError in failure cases inside the module function
  4. handle RuntimeError in main without logging anything else, just by exiting with status code 1 (logging was done in the module function)
  5. handle any other Exception in main by providing descriptive error message and use debug to store error and traceback and exit with status code 1.

Notice on dss initialize

This PR refactors initialize command in main to catch RuntimeError even tho it is not currently raised in the initialize.py module. This is because we expect to raise this type of error once we refactor the command, refactoring is being tracked in #68.

@NohaIhab NohaIhab requested a review from a team as a code owner April 23, 2024 12:16
Copy link
Member

@misohu misohu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments

src/dss/logs.py Outdated Show resolved Hide resolved
src/dss/main.py Show resolved Hide resolved
src/dss/main.py Show resolved Hide resolved
Copy link
Member

@misohu misohu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @NohaIhab

@NohaIhab NohaIhab merged commit 06224bc into main Apr 24, 2024
2 of 3 checks passed
@NohaIhab NohaIhab deleted the kf-5578-refactor-exit-codes-and-logging branch April 24, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add non zero exit code status for errors in dss
2 participants